<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            background-color: pink;
        }
        
        .change {
            background-color: skyblue;
        }
    </style>
</head>

<body>
    <div class="first">文本</div>
    <script>
        var test = document.querySelector('div')
        test.onclick = function() {
            //如果想要保留原先的类名，我们可以这么做
            this.className = 'first change' //多类名选择器
            console.log(test);

        }
    </script>
</body>

</html>